<?php

namespace app\index\service;

use app\common\model\Area;
use app\index\dao\AreaDao;
use app\index\model\UM as UM;

/**
 * Class LawerLocationService
 * @package app\index\service
 */
class LawyerLocationService
{

    private AreaDao $areaDao;

    public function __construct(AreaDao $areaDao)
    {
        $this->areaDao = $areaDao;
    }

    /**
     * 查询
     * @param UM|null $user
     * @return Area
     */
    public function read(UM $user): ?Area
    {
        $memberInfo = $user->memberInfo;
        if (is_null($memberInfo)) {
            return null;
        }

        $areaId = $memberInfo->cityId;

        return Area::where('id', $areaId)
            ->with(['parent'])
            ->find();
    }
}
